package com.palazzisoft.railsystem.model;

import org.apache.commons.lang.builder.EqualsBuilder;
import org.apache.commons.lang.builder.HashCodeBuilder;

/**
 * 
 * @author pablo
 *
 */
public class Pair<T,E> {

	private T first;
	private E second;
	
	public Pair(T first, E second) {
		this.first = first;
		this.second = second;
	}

	public T getFirst() {
		return first;
	}

	public E getSecond() {
		return second;
	}

	@Override
	public int hashCode() {
		return new HashCodeBuilder().append(this.getFirst()).append(this.getSecond()).toHashCode();
	}

	@Override
	public boolean equals(Object obj) {
		if (!(obj instanceof Pair)) {
			return false;
		}

		@SuppressWarnings("unchecked")
		Pair<T,E> other = (Pair<T,E>) obj;
		return new EqualsBuilder().append(this.first, other.getFirst())
				.append(this.second, other.getSecond()).isEquals();
	}
	
	
}
